@include('Admin.public.head')
<body>
@include('Admin.public.menu')
<!-- 引入样式 -->
<div class=" admin-content" id="app">
    <div class="daohang">

    </div>
    <!--充值模态框-->
    <div class="admin-biaogelist">
        <div class="listbiaoti am-cf">
            <ul class="am-icon-yen">奖励记录</ul>
            <dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">奖励记录</a></dl>
            <!--这里打开的是新页面-->
        </div>
        <div class="am-btn-toolbars am-btn-toolbar am-kg am-cf">
            <ul>
				<li>
				    <template>
				        <el-select v-model="keyword.type" placeholder="积分类型">
				            <el-option
				                    size="medium"
				                    v-for="val,index in options"
				                    :key="index"
				                    :label="val.label"
				                    :value="val.value">
				            </el-option>
				        </el-select>
				    </template>
				</li>
				<li>
				    <div class="block">
				        <el-date-picker
				                v-model="keyword.time"
				                type="datetimerange"
				                value-format="yyyy-MM-dd HH:mm:ss"
				                range-separator="~"
				                start-placeholder="开始日期"
				                end-placeholder="结束日期">
				        </el-date-picker>
				    </div>
				</li>
				
                <li>
                    <el-input v-model="keyword.keyword" class="keywords" placeholder="关键词搜索"></el-input>
                </li>
                <li>
                    <el-button type="primary" v-on:click="changeClick()">搜索</el-button>
                </li>
                <li> <el-button type="success" v-on:click="exportDetail()">导出</el-button></li>
                <li> <el-button type="danger" v-on:click="resetOrder()">重置</el-button></li>
            </ul>
        </div>


        <form class="am-form am-g">
            <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
                <thead>
                <tr class="am-success">
                    <th>用户</th>
                    <th>交易总额</th>
                    <th>交易详情</th>
                    <th>时间</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="val,index in RewardsList">
                    <td>@{{ val.user_name }}</td>
                    <td>@{{ val.money }}</td>
                    <th>@{{ val.remark }}</th>
                    <th>@{{ val.time }}</th>
                </tr>
                </tbody>
            </table>
            <!--分页-->
            <ul class="am-pagination am-fr">
                <div class="block">
                    <el-pagination
                            background
                            :page-size="PagesData.per_page"
                            :current-page = "PagesData.current_page"
                            layout="total , prev, pager, next"
                            :total="PagesData.total"
                            @prev-click="changeClick"
                            @next-click="changeClick"
                            @current-change="changeClick">
                        >
                    </el-pagination>
                </div>
            </ul>
			<div>
				总奖励积分:<span class="am-badge am-badge-danger am-radius">@{{ joinTotal }}&nbsp;&nbsp;&nbsp;&nbsp;</span>
				总复销积分:<span class="am-badge am-badge-danger am-radius">@{{ shareTotal }}</span>
			</div>
        </form>

        <script type="text/javascript">

        </script>
        <script>
            var app = new Vue({
                el:"#app",
                data: {
					options: [{
					    value: 1,
					    label: '奖励积分 '
					},{
					    value: 2,
					    label: '复销积分'
					}],
                    RewardsList : [],//转账列表
                    PagesData:[],//分页
                    keyword:{ //关键字搜索
                        keyword:'',
						time:'',
						type:''
                    },
					shareTotal:'',
					joinTotal:''
                },
                //事件
                methods: {
                    //选择当前页
                    changeClick:function(e){
                        var rico = this
                        $.get("/admin/finance/doTransaction",{'_token':'{{csrf_token()}}',class:'rewardsList',page:e,keyword:app.keyword},function (res) {
                            if(res.code){
                                app.RewardsList = res.data.data
                                app.PagesData = res.data
								app.shareTotal = res.shareTotal
								app.joinTotal = res.joinTotal
                            } else {
                                layer.msg(res.data);
                            }
                        });
                    },

                    initialize:function () {
                        var rico = this
                        //用户列表
                        $.get("/admin/finance/doTransaction",{'_token':'{{csrf_token()}}',class:'rewardsList'},function (res) {
                            if(res.code){
                                app.RewardsList = res.data.data
                                app.PagesData = res.data
								app.shareTotal = res.shareTotal
								app.joinTotal = res.joinTotal
                                console.log(  app.PagesData);
                            } else {
                                layer.msg(res.data);
                            }
                        });
                    },
                     //重置
                    resetOrder:function(){
                        location.reload();
                    },
                    //导出记录
                    exportDetail:function () {
                        location.href="/admin/finance/exportDetail?type="+app.keyword.type+'&time='+app.keyword.time+'&keyword='+app.keyword.keyword+'&ClickType=5';
                    }

                },

                //自动执行
                mounted: function () {
                    this.initialize();
                },
            })
        </script>


@include('Admin.public.foot')